<template>
  <div class="loading-state" :class="{ 'full-screen': fullScreen }">
    <div class="loading-content">
      <el-icon class="loading-icon" :size="iconSize">
        <Loading />
      </el-icon>
      <div class="loading-text">{{ text }}</div>
      <div v-if="description" class="loading-description">{{ description }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { Loading } from '@element-plus/icons-vue'

interface Props {
  text?: string
  description?: string
  fullScreen?: boolean
  iconSize?: number
}

withDefaults(defineProps<Props>(), {
  text: '加载中...',
  description: '',
  fullScreen: false,
  iconSize: 32
})
</script>

<style lang="scss" scoped>
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  
  &.full-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
  }
  
  .loading-content {
    text-align: center;
    
    .loading-icon {
      color: var(--color-primary);
      animation: rotate 2s linear infinite;
      margin-bottom: 16px;
    }
    
    .loading-text {
      font-size: 16px;
      color: var(--text-color-primary);
      margin-bottom: 8px;
    }
    
    .loading-description {
      font-size: 14px;
      color: var(--text-color-secondary);
    }
  }
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
</style>
